/*
 * Copyright 2011 Impetus Infotech.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.impetus.teamplan.utils;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.impetus.teamplan.Constants;

/**
 * <Provide Type description>
 * @author amresh.singh
 */
public class StartupListener implements ServletContextListener {

	public void contextInitialized(ServletContextEvent context) {

		KunderaUtils ku = new KunderaUtils();
		try {
			
			String puName = Constants.PERSISTENT_UNIT_NAME;
			System.out.println("Persistent Unit Name:" + puName);
			if(Constants.PERSISTENT_UNIT_NAME_CASSANDRA.equals(puName)) {
				/*Uncomment below lines for running Embedded Cassandra Server  */
				
				//System.out.println("************Starting Kundera-embedded CASSANDRA Server");
				//ku.startCassandraServer();
				//System.out.println("***********Kundera-embedded CASSANDRA Server Started");
			}			

			//ku.loadEntities();
			
		} catch (Exception e) {
			System.out
					.println("Error while Initializing Team Plan application. Details: "
							+ e.getMessage());
			// e.printStackTrace();
		}
	}

	public void contextDestroyed(ServletContextEvent context) {
		// Nothing to do as of now
	}

}
